// 云函数入口文件
const cloud = require('wx-server-sdk')

cloud.init({
  env:'cloud1-4gg2c6jr7a77219d',
  traceUser:true,
});
const db = cloud.database();

// 云函数入口函数
exports.main = async (event, context) => {
  const queryResult = await db.collection('questions').where({
    q_id: event.q_id
  })
  .get()

  if(queryResult.errMsg == 'collection.get:ok'){
    return {
      errcode:0,
      errmsg:"OK",
      data:queryResult.data[0],
    }
  }else{
    return {
      errcode:1,
      errmsg:queryResult.errMsg,
    }
  }
}